/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package model.impl;

import java.util.Date;
import model.EpisodesPackage;
import model.ModelPackage;
import model.Season;

import model.SeasonsPackSeason;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Season</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link model.impl.SeasonImpl#getGroupOfEpisodes <em>Group Of Episodes</em>}</li>
 *   <li>{@link model.impl.SeasonImpl#getSeasonPackSeason <em>Season Pack Season</em>}</li>
 *   <li>{@link model.impl.SeasonImpl#getPremier <em>Premier</em>}</li>
 *   <li>{@link model.impl.SeasonImpl#getEnds <em>Ends</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SeasonImpl extends EntityDescriptionImpl implements Season {
	/**
	 * The cached value of the '{@link #getGroupOfEpisodes() <em>Group Of Episodes</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGroupOfEpisodes()
	 * @generated
	 * @ordered
	 */
	protected EpisodesPackage groupOfEpisodes;

	/**
	 * The cached value of the '{@link #getSeasonPackSeason() <em>Season Pack Season</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSeasonPackSeason()
	 * @generated
	 * @ordered
	 */
	protected SeasonsPackSeason seasonPackSeason;

	/**
	 * The default value of the '{@link #getPremier() <em>Premier</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPremier()
	 * @generated
	 * @ordered
	 */
	protected static final Date PREMIER_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getPremier() <em>Premier</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPremier()
	 * @generated
	 * @ordered
	 */
	protected Date premier = PREMIER_EDEFAULT;

	/**
	 * The default value of the '{@link #getEnds() <em>Ends</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEnds()
	 * @generated
	 * @ordered
	 */
	protected static final Date ENDS_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getEnds() <em>Ends</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEnds()
	 * @generated
	 * @ordered
	 */
	protected Date ends = ENDS_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SeasonImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ModelPackage.Literals.SEASON;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EpisodesPackage getGroupOfEpisodes() {
		return groupOfEpisodes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetGroupOfEpisodes(EpisodesPackage newGroupOfEpisodes, NotificationChain msgs) {
		EpisodesPackage oldGroupOfEpisodes = groupOfEpisodes;
		groupOfEpisodes = newGroupOfEpisodes;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.SEASON__GROUP_OF_EPISODES, oldGroupOfEpisodes, newGroupOfEpisodes);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGroupOfEpisodes(EpisodesPackage newGroupOfEpisodes) {
		if (newGroupOfEpisodes != groupOfEpisodes) {
			NotificationChain msgs = null;
			if (groupOfEpisodes != null)
				msgs = ((InternalEObject)groupOfEpisodes).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.SEASON__GROUP_OF_EPISODES, null, msgs);
			if (newGroupOfEpisodes != null)
				msgs = ((InternalEObject)newGroupOfEpisodes).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.SEASON__GROUP_OF_EPISODES, null, msgs);
			msgs = basicSetGroupOfEpisodes(newGroupOfEpisodes, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.SEASON__GROUP_OF_EPISODES, newGroupOfEpisodes, newGroupOfEpisodes));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SeasonsPackSeason getSeasonPackSeason() {
		if (seasonPackSeason != null && seasonPackSeason.eIsProxy()) {
			InternalEObject oldSeasonPackSeason = (InternalEObject)seasonPackSeason;
			seasonPackSeason = (SeasonsPackSeason)eResolveProxy(oldSeasonPackSeason);
			if (seasonPackSeason != oldSeasonPackSeason) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ModelPackage.SEASON__SEASON_PACK_SEASON, oldSeasonPackSeason, seasonPackSeason));
			}
		}
		return seasonPackSeason;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SeasonsPackSeason basicGetSeasonPackSeason() {
		return seasonPackSeason;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetSeasonPackSeason(SeasonsPackSeason newSeasonPackSeason, NotificationChain msgs) {
		SeasonsPackSeason oldSeasonPackSeason = seasonPackSeason;
		seasonPackSeason = newSeasonPackSeason;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.SEASON__SEASON_PACK_SEASON, oldSeasonPackSeason, newSeasonPackSeason);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSeasonPackSeason(SeasonsPackSeason newSeasonPackSeason) {
		if (newSeasonPackSeason != seasonPackSeason) {
			NotificationChain msgs = null;
			if (seasonPackSeason != null)
				msgs = ((InternalEObject)seasonPackSeason).eInverseRemove(this, ModelPackage.SEASONS_PACK_SEASON__SEASON, SeasonsPackSeason.class, msgs);
			if (newSeasonPackSeason != null)
				msgs = ((InternalEObject)newSeasonPackSeason).eInverseAdd(this, ModelPackage.SEASONS_PACK_SEASON__SEASON, SeasonsPackSeason.class, msgs);
			msgs = basicSetSeasonPackSeason(newSeasonPackSeason, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.SEASON__SEASON_PACK_SEASON, newSeasonPackSeason, newSeasonPackSeason));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Date getPremier() {
		return premier;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPremier(Date newPremier) {
		Date oldPremier = premier;
		premier = newPremier;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.SEASON__PREMIER, oldPremier, premier));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Date getEnds() {
		return ends;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEnds(Date newEnds) {
		Date oldEnds = ends;
		ends = newEnds;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.SEASON__ENDS, oldEnds, ends));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.SEASON__SEASON_PACK_SEASON:
				if (seasonPackSeason != null)
					msgs = ((InternalEObject)seasonPackSeason).eInverseRemove(this, ModelPackage.SEASONS_PACK_SEASON__SEASON, SeasonsPackSeason.class, msgs);
				return basicSetSeasonPackSeason((SeasonsPackSeason)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.SEASON__GROUP_OF_EPISODES:
				return basicSetGroupOfEpisodes(null, msgs);
			case ModelPackage.SEASON__SEASON_PACK_SEASON:
				return basicSetSeasonPackSeason(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ModelPackage.SEASON__GROUP_OF_EPISODES:
				return getGroupOfEpisodes();
			case ModelPackage.SEASON__SEASON_PACK_SEASON:
				if (resolve) return getSeasonPackSeason();
				return basicGetSeasonPackSeason();
			case ModelPackage.SEASON__PREMIER:
				return getPremier();
			case ModelPackage.SEASON__ENDS:
				return getEnds();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ModelPackage.SEASON__GROUP_OF_EPISODES:
				setGroupOfEpisodes((EpisodesPackage)newValue);
				return;
			case ModelPackage.SEASON__SEASON_PACK_SEASON:
				setSeasonPackSeason((SeasonsPackSeason)newValue);
				return;
			case ModelPackage.SEASON__PREMIER:
				setPremier((Date)newValue);
				return;
			case ModelPackage.SEASON__ENDS:
				setEnds((Date)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ModelPackage.SEASON__GROUP_OF_EPISODES:
				setGroupOfEpisodes((EpisodesPackage)null);
				return;
			case ModelPackage.SEASON__SEASON_PACK_SEASON:
				setSeasonPackSeason((SeasonsPackSeason)null);
				return;
			case ModelPackage.SEASON__PREMIER:
				setPremier(PREMIER_EDEFAULT);
				return;
			case ModelPackage.SEASON__ENDS:
				setEnds(ENDS_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ModelPackage.SEASON__GROUP_OF_EPISODES:
				return groupOfEpisodes != null;
			case ModelPackage.SEASON__SEASON_PACK_SEASON:
				return seasonPackSeason != null;
			case ModelPackage.SEASON__PREMIER:
				return PREMIER_EDEFAULT == null ? premier != null : !PREMIER_EDEFAULT.equals(premier);
			case ModelPackage.SEASON__ENDS:
				return ENDS_EDEFAULT == null ? ends != null : !ENDS_EDEFAULT.equals(ends);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (premier: ");
		result.append(premier);
		result.append(", ends: ");
		result.append(ends);
		result.append(')');
		return result.toString();
	}

} //SeasonImpl
